package com.wnxy.admin.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.admin.dto.JChargingPileDto;
import com.wnxy.admin.dto.JChargingStationDto;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wnxy.admin.dto.ChargingStationDto;
import com.wnxy.admin.dto.ReservationChargingStationDto;
import com.wnxy.admin.entity.ChargingStation;
import com.wnxy.admin.entity.Region;
import com.wnxy.admin.mapper.ChargingStationMapper;
import com.wnxy.admin.service.IChargingStationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 充电站 服务实现类
 * </p>
 *
 * @author All
 * @since 2023-11-29
 */
@Service
public class ChargingStationServiceImpl extends ServiceImpl<ChargingStationMapper, ChargingStation> implements IChargingStationService {

    private final RedisTemplate redisTemplate;
    private final ChargingStationMapper chargingStationMapper;
    private final ElasticsearchRestTemplate elasticsearchRestTemplate;
    public ChargingStationServiceImpl(RedisTemplate redisTemplate, ChargingStationMapper chargingStationMapper, ElasticsearchRestTemplate elasticsearchRestTemplate){
        this.redisTemplate = redisTemplate;
        this.chargingStationMapper = chargingStationMapper;
        this.elasticsearchRestTemplate = elasticsearchRestTemplate;
    }

    @Override
    public PageInfo<JChargingStationDto> findByPage(String chargingStationName,int pageNum, int pageSize) {
        //1.设置页码和每页大小
        PageHelper.startPage(pageNum, pageSize);
        //2.调用DAO层查询
        List<JChargingStationDto> list = chargingStationMapper.findRAll(chargingStationName);
        //3.返回PageInfo对象
        return new PageInfo<>(list);
    }

    @Override
    public void addAddress(ChargingStation chargingStation) {

    }

    @Override
    public ChargingStation findByNumbers(String number) {
        return chargingStationMapper.findByNumbers(number);
    }

    @Override
    public List<ReservationChargingStationDto> getAllChargingStationsWithPiles() {
        return chargingStationMapper.getAllChargingStationsWithPiles();
    }
}
